package 单例;

/**
 * @Author Klys
 * @Date 2023/3/5 14:01
 * @Description
 * @Version 1.0
 */

//懒汉式     线程安全类
public class Lazy2 {

    private static Lazy2 instance;

    private Lazy2() {

    }

    //对拿对象的方法加锁
    public static synchronized Lazy2 getInstance() {
        if (instance == null) {
            instance = new Lazy2();
        }
        return instance;
    }
}
